package de.karlNet.login.attributeMapper;

import java.util.List;

import javax.naming.NamingException;
import javax.naming.directory.Attributes;

import org.springframework.stereotype.Component;

import de.karlNet.sambamanager.ldapModel.LdapObject;
import de.karlNet.sambamanager.ldapModel.dns.LdapDNSZone;

@Component
public class DnsZoneExtractor extends LdapObjectExtractor {

	private LdapDNSZone getLdapDNSZone(Attributes attributes)
			throws NamingException {
		String dn = this.tryToGetString("distinguishedname", attributes,
				tryToGetString("dn", attributes));
		String dc = this.tryToGetString("dc", attributes,
				tryToGetString("dc", attributes));
		return new LdapDNSZone(dc, dn);
	}

	@Override
	public LdapObject extract(Attributes attributes, List<String> objectClasses)
			throws NamingException {
		if (objectClasses.contains("dnsZone")) {
			return this.getLdapDNSZone(attributes);
		}
		return null;
	}
}
